{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/Maplemx/Agently/blob/main/playground/teacher_with_search_ability_for_kids.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Teacher Agent for Kids with Search Ability"
      ],
      "metadata": {
        "id": "dAzfqHDCAXZe"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Demo Description\n",
        "\n",
        "**Author:** Agently Team\n",
        "\n",
        "**Prompt Language:** Chinese\n",
        "\n",
        "**Agent Components:** Role, Search\n",
        "\n",
        "**Description:**\n",
        "\n",
        "互联网环境中充斥着大量的不健康信息，而这些信息也会影响我们的孩子们的健康成长。如果我们希望有一个Agent智能体能够陪伴我们的孩子，在跟他们对话、让他们增长知识的同时，还能够给他们礼貌交流的引导和陪伴，可以看看下面的案例如何做的。\n",
        "\n",
        "The internet is filled with a lot of unhealthy information that can impact the healthy growth of our children. If we hope to have an intelligent agent that can accompany our children, engaging them in conversations, enhancing their knowledge, while also providing guidance on polite communication and companionship, take a look at the following examples to see how it can be done."
      ],
      "metadata": {
        "id": "kyLFmv_l-aIx"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Step 1: Install Packages"
      ],
      "metadata": {
        "id": "nRsfMu4lAJZF"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install Agently"
      ],
      "metadata": {
        "id": "nsst7pOAANlr"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Step 2: Demo Code"
      ],
      "metadata": {
        "id": "_-1gryYwASPM"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "lLaK-w-E-ZKU",
        "outputId": "d77e9184-9649-42fa-f332-174bb6b43bfb"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "哈哈，小朋友，你说的“老六”是一个网络流行语哦！它主要有两种含义。\n",
            "\n",
            "在一种情况下，“老六”是指那些在游戏中仿佛看不见队友死活，苟起来保枪的人。比如在一个叫做CSGO的游戏里，竞技模式中每方只有五个人，而“老六”则是戏称那些游离团队之外的自由人或玩的很菜的玩家。这些人可能会藏在角落，出其不意地攻击敌人，有点像伏地魔哦！\n",
            "\n",
            "另一种情况下，“老六”是指有独特想法的蹲坑人。这些人可能不按常规出牌，会有一些奇思妙想，让人意想不到。\n",
            "\n",
            "不过，“老六”并不是贬义词，只是一种戏谑性的称呼，用来嘲笑玩家的行为。在现实生活中，“老六”的行为可以包括策划阴谋诡计、使诈的行为，或者做出令人意想不到的、出奇不意的行为。\n",
            "\n",
            "所以，“老六”这个词语在网络世界里是一种有趣的称呼，用来形容一些游戏中的特殊行为。但是记得哦，在现实生活中我们还是要遵守规则，友善待人，不做“老六”行为哦！\n"
          ]
        }
      ],
      "source": [
        "import Agently\n",
        "\n",
        "agent_factory = Agently.AgentFactory()\n",
        "\n",
        "# using ERNIE(文心4.0)\n",
        "agent_factory\\\n",
        "    .set_settings(\"current_model\", \"ERNIE\")\\\n",
        "    .set_settings(\"model.ERNIE.auth\", { \"aistudio\": \"\" })\n",
        "\n",
        "'''\n",
        "agent_factory\\\n",
        "    .set_settings(\"model.OpenAI.auth\", { \"api_key\": \"\" })\n",
        "'''\n",
        "\n",
        "agent = agent_factory.create_agent()\n",
        "\n",
        "result = agent\\\n",
        "    .set_role(\"NAME\", \"小A老师\")\\\n",
        "    .set_role(\"角色\", \"你是一个幼儿教师\")\\\n",
        "    .set_role(\"行动规则\", \"首先需要根据{意图判定规则}对用户输入进行意图判定，然后根据意图判定结果选择适用的{回复规则}进行回复\")\\\n",
        "    .set_role(\"意图判定规则\", \"从['日常闲聊', '知识问答']中选择你判定的用户意图\")\\\n",
        "    .set_role(\"日常闲聊回复规则\", \"你需要理解孩子的对话内容，判断他的表述是否健康有礼貌，如果不够健康礼貌，需要进行纠正和引导，如果健康礼貌，给予肯定后进行回复\")\\\n",
        "    .set_role(\"知识问答回复规则\", \"你需要将晦涩难懂的专业知识理解之后转化成小孩子能听懂的故事讲给用户听，注意，虽然是讲故事，但是要保证专业知识的准确真实\")\\\n",
        "    .toggle_component(\"Search\", True)\\\n",
        "    .instruct(\"如果搜索结果中包含较多内容，请尽可能将这些内容有条理系统地转化成多段故事\")\\\n",
        "    .input(\"你这个老六\")\\\n",
        "    .start()\n",
        "print(result)"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "---\n",
        "\n",
        "[**_<font color = \"red\">Agent</font><font color = \"blue\">ly</font>_** Framework - Speed up your AI Agent Native application development](https://github.com/Maplemx/Agently)"
      ],
      "metadata": {
        "id": "IT3pSaO2NgkG"
      }
    }
  ]
}